<!DOCTYPE HTML>
<html>
<head>
<title>Goto | AutoHotkey</title>
<meta name="description" content="The Goto statement jumps to the specified label and continues execution." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
<script type="text/javascript">$(function(){0<=window.navigator.userAgent.toLowerCase().indexOf("ucbrowser")&&CaoNiMaDeUc()})</script>
</head>
<body>

<h1>Goto</h1>

<p>跳转到指定的标签并继续执行.</p>

<pre class="Syntax"><span class="func">Goto</span>, Label</pre>
<h2>参数</h2>
<dl>

  <dt>Label(标签)</dt>
  <dd><p>跳转目标的<a href="../misc/Labels.htm">标签</a>名.</p></dd>

</dl>

<h2>备注</h2>
<p>使用类似 %MyLabel% 的动态标签时, 如果目标标签不存在则会显示错误对话框. 要避免此问题, 请预先调用 <a href="IsLabel.htm">IsLabel()</a>. 例如:</p>
<pre>if IsLabel(VarContainingLabelName)
    Goto %VarContainingLabelName%</pre>
<p>不鼓励使用 Goto, 因为它通常让脚本不容易阅读且难以维护. 考虑使用 <a href="Else.htm">Else</a>, <a href="Block.htm">区块</a>, <a href="Break.htm">Break</a> 和 <a href="Continue.htm">Continue</a> 来代替 Goto.</p>
<h2>相关</h2>
<p><a href="Gosub.htm">Gosub</a>, <a href="Return.htm">Return</a>, <a href="IsLabel.htm">IsLabel()</a>, <a href="Else.htm">Else</a>, <a href="Block.htm">区块</a>, <a href="Break.htm">Break</a>, <a href="Continue.htm">Continue</a></p>
<h2>示例</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>Goto, MyLabel
<em>; ...</em>
MyLabel:
Sleep, 100
<em>; ...</em></pre>
</div>

</body>
</html>